﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Nhom14_HTTTHD_BuyMe.function
{
    public class Message
    {
        static public int AddMessage(int from_account, int to_account, string message)
        {
            try
            {
                using (websitebrokenEntities context = new websitebrokenEntities())
                {
                    message obj = new message();
                    obj.id_from_username = from_account;
                    obj.id_to_username = to_account;
                    obj.message1 = message;
                    obj.timestamp = DateTime.Now;
                    obj.parent = 0;
                    context.messages.AddObject(obj);
                    context.SaveChanges();

                    return obj.id;
                }
            }
            catch
            {
                return 0;
            }
        }
    }
}